import { lazy } from 'react';
import { MainLayout } from '../layouts/MainLayout';

// 静态路由配置
export const staticRoutes = [
  {
    path: '/login',
    component: lazy(() => import('../pages/Login')),
    meta: {
      title: '登录',
      requiresAuth: false
    }
  },
  {
    path: '/404',
    component: lazy(() => import('../pages/NotFound')),
    meta: {
      title: '404',
      requiresAuth: false
    }
  }
];

// 动态路由配置
export const asyncRoutes = [
  {
    path: '/',
    component: MainLayout,
    meta: {
      title: '首页',
      requiresAuth: true
    },
    children: [
      {
        path: 'dashboard',
        component: lazy(() => import('../pages/Dashboard')),
        meta: {
          title: '仪表盘',
          requiresAuth: true
        }
      },
      {
        path: 'profile',
        component: lazy(() => import('../pages/Profile')),
        meta: {
          title: '个人中心',
          requiresAuth: true
        }
      },
      {
        path: 'system/menu',
        component: lazy(() => import('../pages/MenuManagement')),
        meta: {
          title: '菜单管理',
          requiresAuth: true
        }
      },
      // 添加用户管理路由
      {
        path: 'system/user',
        component: lazy(() => import('../pages/UserManagement')),
        meta: {
          title: '用户管理',
          requiresAuth: true
        }
      },
      // 添加角色管理路由
      {
        path: 'system/role',
        component: lazy(() => import('../pages/RoleManagement')),
        meta: {
          title: '角色管理',
          requiresAuth: true
        }
      },
      // 添加权限管理路由
      {
        path: 'system/permission',
        component: lazy(() => import('../pages/PermissionManagement')),
        meta: {
          title: '权限管理',
          requiresAuth: true
        }
      }
    ]
  }
];

// 所有路由
export const routes = [...staticRoutes, ...asyncRoutes];